home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- '''ZODB-defined exceptions
-
- $Id: POSException.py 40425 2005-11-30 07:01:03Z fdrake $'''
- from ZODB.utils import oid_repr, readable_tid_repr
-
- def _fmt_undo(oid, reason):
- if not reason or ': %s' % reason:
- pass
- s = ''
- return 'Undo error %s%s' % (oid_repr(oid), s)
-
-
- class POSError(StandardError):
- '''Persistent object system error.'''
- pass
-
-
- class POSKeyError(KeyError, POSError):
- '''Key not found in database.'''
-
- def __str__(self):
- return oid_repr(self.args[0])
-
-
-
- class TransactionError(POSError):
- '''An error occurred due to normal transaction processing.'''
- pass
-
-
- class TransactionFailedError(POSError):
- '''Cannot perform an operation on a transaction that previously failed.
-
- An attempt was made to commit a transaction, or to join a transaction,
- but this transaction previously raised an exception during an attempt
- to commit it. The transaction must be explicitly aborted, either by
- invoking abort() on the transaction, or begin() on its transaction
- manager.
- '''
- pass
-
-
- class ConflictError(TransactionError):
- """Two transactions tried to modify the same object at once.
-
- This transaction should be resubmitted.
-
- Instance attributes:
- oid : string
- the OID (8-byte packed string) of the object in conflict
- class_name : string
- the fully-qualified name of that object's class
- message : string
- a human-readable explanation of the error
- serials : (string, string)
- a pair of 8-byte packed strings; these are the serial numbers
- related to conflict. The first is the revision of object that
- is in conflict, the currently committed serial. The second is
- the revision the current transaction read when it started.
- data : string
- The database record that failed to commit, used to put the
- class name in the error message.
-
- The caller should pass either object or oid as a keyword argument,
- but not both of them. If object is passed, it should be a
- persistent object with an _p_oid attribute.
- """
-
- def __init__(self, message = None, object = None, oid = None, serials = None, data = None):
- if message is None:
- self.message = 'database conflict error'
- else:
- self.message = message
- if object is None:
- self.oid = None
- self.class_name = None
- else:
- self.oid = object._p_oid
- klass = object.__class__
- self.class_name = klass.__module__ + '.' + klass.__name__
- if oid is not None:
- if not self.oid is None:
- raise AssertionError
- self.oid = oid
-
- if data is not None:
- get_pickle_metadata = get_pickle_metadata
- import ZODB.utils
- self.class_name = '%s.%s' % get_pickle_metadata(data)
-
- self.serials = serials
-
-
- def __str__(self):
- extras = []
- if self.oid:
- extras.append('oid %s' % oid_repr(self.oid))
-
- if self.class_name:
- extras.append('class %s' % self.class_name)
-
- if self.serials:
- (current, old) = self.serials
- extras.append('serial this txn started with %s' % readable_tid_repr(old))
- extras.append('serial currently committed %s' % readable_tid_repr(current))
-
- if extras:
- return '%s (%s)' % (self.message, ', '.join(extras))
- else:
- return self.message
-
-
- def get_oid(self):
- return self.oid
-
-
- def get_class_name(self):
- return self.class_name
-
-
- def get_old_serial(self):
- return self.serials[1]
-
-
- def get_new_serial(self):
- return self.serials[0]
-
-
- def get_serials(self):
- return self.serials
-
-
-
- class ReadConflictError(ConflictError):
- '''Conflict detected when object was loaded.
-
- An attempt was made to read an object that has changed in another
- transaction (eg. another thread or process).
- '''
-
- def __init__(self, message = None, object = None, serials = None):
- if message is None:
- message = 'database read conflict error'
-
- ConflictError.__init__(self, message = message, object = object, serials = serials)
-
-
-
- class BTreesConflictError(ConflictError):
- '''A special subclass for BTrees conflict errors.'''
- msgs = [
- 'Conflicting bucket split',
- 'Conflicting changes',
- 'Conflicting delete and change',
- 'Conflicting delete and change',
- 'Conflicting inserts or deletes',
- 'Conflicting deletes',
- 'Conflicting inserts',
- 'Conflicting deletes, or delete and change',
- 'Conflicting deletes, or delete and change',
- 'Conflicting deletes',
- 'Empty bucket from deleting all keys',
- 'Conflicting changes in an internal BTree node',
- 'Empty bucket in a transaction']
-
- def __init__(self, p1, p2, p3, reason):
- self.p1 = p1
- self.p2 = p2
- self.p3 = p3
- self.reason = reason
-
-
- def __repr__(self):
- return 'BTreesConflictError(%d, %d, %d, %d)' % (self.p1, self.p2, self.p3, self.reason)
-
-
- def __str__(self):
- return 'BTrees conflict error at %d/%d/%d: %s' % (self.p1, self.p2, self.p3, self.msgs[self.reason])
-
-
-
- class DanglingReferenceError(TransactionError):
- '''An object has a persistent reference to a missing object.
-
- If an object is stored and it has a reference to another object
- that does not exist (for example, it was deleted by pack), this
- exception may be raised. Whether a storage supports this feature,
- it a quality of implementation issue.
-
- Instance attributes:
- referer: oid of the object being written
- missing: referenced oid that does not have a corresponding object
- '''
-
- def __init__(self, Aoid, Boid):
- self.referer = Aoid
- self.missing = Boid
-
-
- def __str__(self):
- return 'from %s to %s' % (oid_repr(self.referer), oid_repr(self.missing))
-
-
-
- class VersionError(POSError):
- '''An error in handling versions occurred.'''
- pass
-
-
- class VersionCommitError(VersionError):
- '''An invalid combination of versions was used in a version commit.'''
- pass
-
-
- class VersionLockError(VersionError, TransactionError):
- '''Modification to an object modified in an unsaved version.
-
- An attempt was made to modify an object that has been modified in an
- unsaved version.
- '''
- pass
-
-
- class UndoError(POSError):
- '''An attempt was made to undo a non-undoable transaction.'''
-
- def __init__(self, reason, oid = None):
- self._reason = reason
- self._oid = oid
-
-
- def __str__(self):
- return _fmt_undo(self._oid, self._reason)
-
-
-
- class MultipleUndoErrors(UndoError):
- '''Several undo errors occurred during a single transaction.'''
-
- def __init__(self, errs):
- UndoError.__init__(self, *errs[0])
- self._errs = errs
-
-
- def __str__(self):
- return []([ _fmt_undo(*pair) for pair in self._errs ])
-
-
-
- class StorageError(POSError):
- '''Base class for storage based exceptions.'''
- pass
-
-
- class StorageTransactionError(StorageError):
- '''An operation was invoked for an invalid transaction or state.'''
- pass
-
-
- class StorageSystemError(StorageError):
- '''Panic! Internal storage error!'''
- pass
-
-
- class MountedStorageError(StorageError):
- '''Unable to access mounted storage.'''
- pass
-
-
- class ReadOnlyError(StorageError):
- '''Unable to modify objects in a read-only storage.'''
- pass
-
-
- class TransactionTooLargeError(StorageTransactionError):
- '''The transaction exhausted some finite storage resource.'''
- pass
-
-
- class ExportError(POSError):
- """An export file doesn't have the right format."""
- pass
-
-
- class Unsupported(POSError):
- '''A feature was used that is not supported by the storage.'''
- pass
-
-
- class InvalidObjectReference(POSError):
- '''An object contains an invalid reference to another object.
-
- An invalid reference may be one of:
-
- o A reference to a wrapped persistent object.
-
- o A reference to an object in a different database connection.
-
- TODO: The exception ought to have a member that is the invalid object.
- '''
- pass
-
-
- class ConnectionStateError(POSError):
- """A Connection isn't in the required state for an operation.
-
- o An operation such as a load is attempted on a closed connection.
-
- o An attempt to close a connection is made while the connection is
- still joined to a transaction (for example, a transaction is in
- progress, with uncommitted modifications in the connection).
- """
- pass
-
-